import json

import requests

data = {
    'aiType': '2',
    'from': 'en',
    'select': 'all',
    'sentence': '[{"id":"WBwX4GXKle","paraIdx":0,"src":"cat\n","dst":"猫\n","metadata":"","metaData":[]},{"id":"1z92vr24YB","paraIdx":1,"src":"\n","dst":"\n","metadata":"","metaData":[]}]',
    'to': 'zh',
    'type': '1',
    'typeID': 'kPRNR5qepP',
}
url = "https://fanyi.baidu.com/ai/smartSug"

headers = {
    'Accept': '*/*',
    # 'Accept-Encoding': 'gzip, deflate, br',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Connection': 'keep-alive',
    'Content-Length': '399',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Cookie': 'BIDUPSID=8AC47C91EB24CEF54D60954251023E56; PSTM=1662460286; REALTIME_TRANS_SWITCH=1; HISTORY_SWITCH=1; FANYI_WORD_SWITCH=1; SOUND_PREFER_SWITCH=1; SOUND_SPD_SWITCH=1; BAIDUID=1C81DFCBB13256AD62B7F7C55C088BF0:FG=1; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1710755946; BDUSS=l1VjEyUm1CMjkyODFHVjktak9SR35rVVQ3RUhTVmxVMUR2clh4ODhsOHo2WTltRVFBQUFBJCQAAAAAAQAAAAEAAABFqE5lVm9rdGEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADNcaGYzXGhmNG; BDUSS_BFESS=l1VjEyUm1CMjkyODFHVjktak9SR35rVVQ3RUhTVmxVMUR2clh4ODhsOHo2WTltRVFBQUFBJCQAAAAAAQAAAAEAAABFqE5lVm9rdGEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADNcaGYzXGhmNG; H_PS_PSSID=60236_60326_60334_60297_60345; H_WISE_SIDS=60236_60326_60334_60297_60345; H_WISE_SIDS_BFESS=60236_60326_60334_60297_60345; BA_HECTOR=0h0la400a12h04840h0h2k21865q4s1j6qibq1u; BDORZ=FFFB88E999055A3F8A630C64834BD6D0; BAIDUID_BFESS=1C81DFCBB13256AD62B7F7C55C088BF0:FG=1; ZFY=QA1Cl0N7KouaHe:A8lZEMeUihNzxy5WzBRcUKjovdk5Q:C; ab_sr=1.0.1_MjA0ZjRiOGVlNGI0YTIzYmIwMjJjYmE1ZDAwMzk0NmNkMGJhZWJkNTk5MTM1YjEzZjkxY2I4NzExZDQzMWQxOTI1ZDY3MTVjNDg4NzgyZDMxMzRkM2I1NWUzMDQ2NGNhMzRhNTdlMjY4MzNjNDM5YzgzNTk4N2UyOWQyZmI3NmExYTYzZDlkZjg4OGNlNTlmMzQ5MjczYmZkMDYzODIzZQ==; RT="z=1&dm=baidu.com&si=b1c53aa9-485b-472c-996b-583cb0eb1067&ss=lxftrwtz&sl=2&tt=4dj&bcn=https%3A%2F%2Ffclog.baidu.com%2Flog%2Fweirwood%3Ftype%3Dperf&ld=c05"',
    'Host': 'fanyi.baidu.com',
    'Origin': 'https://fanyi.baidu.com',
    'Referer': 'https://fanyi.baidu.com/mtpe-individual/multimodal?query=cat%0A&lang=en2zh&ext_channel=Aldtype',
    'sec-ch-ua': '"Chromium";v="9", "Not?A_Brand";v="8"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'Sec-Fetch-Dest': 'empty',
    'Sec-Fetch-Mode': 'cors',
    'Sec-Fetch-Site': 'same-origin',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)',
}
resp = requests.post(url=url, headers=headers, data=data)
resp.encoding = 'utf-8'

json_str = json.loads(resp.text)
print(json_str)
